package Controller;

import Helper.*;
import Model.*;

import java.util.ArrayList;

public class UserController {
    private static User u = null;

    public static boolean login(String username, String password){
        UserM userM = new UserM();

        u = userM.login(username, password);


        if( u != null ){
            Helper.setSession(0, u.name);
            Helper.setSession(1, String.valueOf(u.id));

            return true;
        }else{
            Helper.waitter();

            return false;
        }
    }

    public static boolean signup(String username, String password){
        UserM userM = new UserM();

        return userM.signup(username, password);
    }

    public static ArrayList<Order> listOrders(){
        return u.getOrders();
    }

    public static boolean buy(int id, int amount, float price){
        return u.buy(id, amount, price);
    }
}
